This sample code shows the use of the Start Event (Report Object). Modify the following sample code to fit your needs.
Dim rptView As CRPEAuto.View
Dim test As Integer
Private Sub Start_Click()
'Starts up report for report event Start
On Error GoTo ErrorHandler
Set repEvs = crsApp.OpenReport("c:\crw\reports\xtreme\www.sales.rpt")
test = MsgBox("Event default: Enabled = " & _
repEvs.EventInfo.StartStopEventEnabled & Chr(13) & _
Chr(13) & "Disable event?", vbYesNo)
If test = vbYes Then
repEvs.EventInfo.StartStopEventEnabled = False
MsgBox "Check event does not occur when report starts"
Set rptView = repEvs.Preview
rptView.Close
Else
repEvs.EventInfo.StartStopEventEnabled = True
test = MsgBox("Check event occurs when report starts" & _
Chr(13) & Chr(13) & "Use default behaviour for test? ", vbYesNo)
If test = vbYes Then
def = True
Set rptView = repEvs.Preview
rptView.Close
Else
def = False
repEvs.Preview
End If
End If
Exit Sub ' Exit to avoid handler.
ErrorHandler:
If crsApp.LastErrorCode <> 0 Then
MsgBox "Unexpected application error: " & _
crsApp.LastErrorCode & "->" & crsApp.LastErrorString
End If
If repEvs.LastErrorCode <> 0 Then
MsgBox "Unexpected application error: " & _
repEvs.LastErrorCode & "->" & repEvs.LastErrorString
End If
If Err.Number <> 0 Then
MsgBox "Unexpected VB error: " & Err.Number & _
"->" & Err.Description
End If
Call ResetErr
repEvs.ClearError
Resume Next
End Sub
Private Sub repEvs_Start(ByVal Destination As CRPEAuto.CRPrintingDestination, _
useDefault As Boolean)
'executed when report starts - test with and without default behaviour
If def Then
'test with default behaviour
MsgBox "Report Start event" & Chr(13) & Chr(13) & "Parameters:" & _
Chr(13) & "Destination(window=1): " & Destination & _
Chr(13) & "useDefault: " & useDefault & Chr(13) & _
Chr(13) & "Report should now start"
Else
'test with no default behaviour
useDefault = False
MsgBox "Report Start event" & Chr(13) & Chr(13) & _
"Parameters:" & Chr(13) & "Destination(window=1): " & _
Destination & Chr(13) & "useDefault: " & useDefault & _
Chr(13) & Chr(13) & "Report should NOT start"
End If
End Sub
Seagate Software IMG Holdings, Inc. http://www.seagatesoftware.com Support services: http://support.seagatesoftware.com |